#!usr/bin/env python
# -*- coding:utf-8 -*-
# user nanme: Mr.zhang
# data time : 2022/11/18   5:21 下午
# project   : star_run.py
# IDE       : PyCharm
# email     :17600960626@163.com
import os
import time

from auto_xposed.auto_start import Auto_start
from init_data.get_devices import init_dev
from init_data.init_datas import data_init
from public.install_apk import ins_apk
from public.uninstall import Auto_uninstall
from public.start_java import run_star

class star():

    def __init__(self):
        self.s1 = input('请输入安装输入法apk简称如：ziyan、swk：')
        self.corpus_mode = input("请选择当前运行的模式，输入0为纠错，输入1为单语料测试，输入2为混合输入测试:")
        self.mix_path = "/data/corpus"  #混输路径
        self.single_path = "/data/corpus_single" #单输入路径
        self.fuzzed_path ="/data/fuzzed" #纠错路径
        self.layout = "/data/layout" #layout路径
        self.data_init = data_init() #初始化设备、语料、路径、devices
        self.data_dev = init_dev() #数据入库绑定、清理layout文件，重新推送对应layout
        self.data_unis = Auto_uninstall() #卸载已安装的输入法及Xposed工具
        self.data_install = ins_apk() #多线程安装所需apk
        self.runs = Auto_start()


    def start_run(self):
        self.data_unis.apk_uninstall(self.s1)
        self.data_unis.un_layout()
        self.data_dev.initi_The_Device()
        self.data_init.boot_init(self.corpus_mode,self.mix_path,self.single_path,self.fuzzed_path)
        self.data_init.lang_devices()
        self.data_init.init_layout(self.layout)
        self.data_install.install_apk()
        self.runs.start_run(self.corpus_mode,self.s1)
        print("设备重启倒计时……")
        a =0
        while a<60:
            time.sleep(1)
            print("%s 秒"%a)
            a+=1
        # run_star(self.corpus_mode)#目前存在bug，自动化运行会造成python崩溃

if __name__ == '__main__':
    run=star()
    run.start_run()



